//
//  ViewControllerPageMenu.swift
//  viewcontroller_test
//
//  Created by 潘茹燕 on 16/4/12.
//  Copyright © 2016年 海南开工信息技术有限公司. All rights reserved.
//

import UIKit

class ViewControllerPageMenu: UIViewController {

    
    @IBOutlet weak var button: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        
        
        //let pageMenuView = KGPageMenuView(pages: ["全部", "待付款", "待发货", "待收货", "待评价", "已完成", "已取消"], frame: CGRect(x: 0, y: 0, width: Int(view.frame.width), height: 40))
        
        
        
        let pageMenuView = KGPageMenuView(frame: CGRect(x: 0, y: 0, width: Int(view.frame.width), height: 40))
        
        view.addSubview(pageMenuView)
        
        pageMenuView.setPages(["全部", "待付款", "待发货", "待收货", "待评价", "已完成", "已取消"])
        pageMenuView.setPages(["全部", "待付款", "待发货", "待收货", "待评价", "已完成", "已取消"])
        
        pageMenuView.Font = UIFont.systemFontOfSize(11)
        
        
        pageMenuView.translatesAutoresizingMaskIntoConstraints = false
        NSLayoutConstraint(item: pageMenuView, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: topLayoutGuide, attribute: NSLayoutAttribute.Bottom, multiplier: 1.0, constant: 0.0).active = true
        
        NSLayoutConstraint(item: pageMenuView, attribute: NSLayoutAttribute.Leading, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Leading, multiplier: 1.0, constant: 0.0).active = true
        
        NSLayoutConstraint(item: pageMenuView, attribute: NSLayoutAttribute.Trailing, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.Trailing, multiplier: 1.0, constant: 0.0).active = true
        
        
        
        NSLayoutConstraint(item: pageMenuView, attribute:NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.GreaterThanOrEqual, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1.0, constant: 30).active = true
        
        
        
        
        pageMenuView.addTarget(self, action: #selector(ViewControllerPageMenu.selectMenuItem(_:)))
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func selectMenuItem(sender: AnyObject) {
        NSLog("\(sender)")
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
